package com.neusoft.news.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet Demo
 *
 * @author wh
 * @ClassName: DemoServlet
 * @Description: 一个Demo 示例
 * @date 2021年5月22日
 * @since JDK 1.8
 */
@WebServlet(name = "demo", urlPatterns = "/a", loadOnStartup = 1)
public class DemoServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);

        System.out.println("AGet请求");
        req.getRequestDispatcher("/WEB-INF/jsp/user.jsp")
                .forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);

        System.out.println("APost请求");
        resp.getWriter().println("APost请求");
    }
}
